import {
    getBanner,
    getPersonalized, getNewSongPush,
    getNewAlbums, getMvAll, getSongUrl,
    getLyric
} from '../../api/services/api'
import { getUserDetail } from '../../api/services/user'
export default {
    namespaced: true,
    state: {
        banners: [],
        personalizedList: [],
        newSongPushList: [],
        //当前新歌种类
        newSongPushType: '0',
        newAlbums: [],
        mvList: [],
        mvType: '全部',
    },
    mutations: {
        changeBaners(state, arr) {
            state.banners = [...arr];
            console.log(state.banners);
        },
        changeActiveIndex(state, val) {
            state.activeIndex = val;
        },
        changePersonalizedList(state, arr) {
            state.personalizedList = [...arr];
        },
        changeNewSongPushList(state, arr) {
            state.newSongPushList = arr.slice(0, 8);
            console.log(state.newSongPushList);
        },
        //改变新歌种类
        changeNewSongPushType(state, val) {
            state.newSongPushType = val;
        },

        //改变新专辑数组
        changeNewAlbums(state, arr) {
            state.newAlbums = [...arr];
        },
        changeMvList(state, arr) {
            state.mvList = [...arr]
            console.log('我mv怎么没了', state.mvList);
        },
        //改变Mv种类
        changeMvType(state, val) {
            state.mvType = val;
        },

    },
    actions: {
        //获取轮播图
        async getBanner(context) {
            const data = await getBanner()
            // console.log(data);
            context.commit('changeBaners', data.banners);
        },
        //获取推荐歌单 getPersonalized
        async getPersonalized(context) {
            const data = await getPersonalized('10');
            // console.log('推荐歌单', data);
            context.commit('changePersonalizedList', data.result);
        },

        //获取新歌推送  getNewSongPush
        async getNewSongPush(context) {
            const data = await getNewSongPush(context.state.newSongPushType);
            // console.log('新歌速递', data);
            context.commit('changeNewSongPushList', data.data);

        },

        //获取新专辑  getNewAlbums
        async getNewAlbums(context) {
            const data = await getNewAlbums();
            // console.log('新专辑', data);
            context.commit('changeNewAlbums', data.albums);

        },

        //获取mv
        async getMvAll(context) {
            const data = await getMvAll(context.state.mvType, '全部', '最热', 30, 1);
            console.log('全部mv', data);
            context.commit('changeMvList', data.data);

        },
    }
}